const { paths } = require('react-app-rewired');
const path = require('path');
//alias
const rewireAliases = require('react-app-rewire-aliases');
// 热重载
const rewireReactHotLoader = require('react-app-rewire-hot-loader');
// postcss
const rewirePostcss = require('react-app-rewire-postcss');
// pxtorem
const pxtorem = require('postcss-pxtorem');


/* config-overrides.js */
module.exports = function override(config, env) {
    config = rewireAliases.aliasesOptions({
        '@css': path.resolve(__dirname, `${paths.appSrc}/assets/css`)
    })(config, env);
    config = rewireReactHotLoader(config, env);
    config = rewirePostcss(config, {
        plugins: () => [
            pxtorem({
                rootValue: 32,
                propList: ["*"]
            }),
            require('postcss-preset-env')({
                autoprefixer: {
                    browsers: ["Android >= 4.0", "iOS >= 7"]
                }
            }),
        ]
    });

    return config;
}